package com.dongdongshop.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.dongdongshop.mapper.TbContentCategoryMapper;
import com.dongdongshop.pojo.TbBrand;
import com.dongdongshop.pojo.TbBrandExample;
import com.dongdongshop.pojo.TbContentCategory;
import com.dongdongshop.pojo.TbContentCategoryExample;
import com.dongdongshop.service.ContentCategoryService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.Resource;
import java.util.List;

@Service
@org.springframework.stereotype.Service
public class ContentCategoryServiceImpl implements ContentCategoryService {

    private static final Logger logger = LoggerFactory.getLogger(ContentCategoryServiceImpl.class);

    @Resource
    private TbContentCategoryMapper tbContentCategoryMapper;

    @Override
    public PageInfo<TbContentCategory> getListContentCategory(Integer pageNumber, Integer pageSize) {
        PageHelper.startPage(pageNumber,pageSize);
        List<TbContentCategory> tbContentCategories = tbContentCategoryMapper.selectByExample(new TbContentCategoryExample());
        PageInfo<TbContentCategory> pageInfo = new PageInfo<>(tbContentCategories);
        logger.info("执行成功");
        return pageInfo;
    }

    @Override
    public int insertCategory(TbContentCategory tbContentCategory) {
        return tbContentCategoryMapper.insertSelective(tbContentCategory);
    }

    @Override
    public TbContentCategory selectCateById(Long id) {
        return tbContentCategoryMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateCategory(TbContentCategory contentCategory) {
        return tbContentCategoryMapper.updateByPrimaryKeySelective(contentCategory);
    }

    @Override
    public int deleteBatch(Long[] ids) {
        return tbContentCategoryMapper.deleteCateBatch(ids);
    }

    @Override
    public List<TbContentCategory> getContentCategory() {
        return tbContentCategoryMapper.selectByExample(new TbContentCategoryExample());
    }
}
